package cn.edu.tju.elm.mapper;

import cn.edu.tju.elm.dto.CartResponseDTO;
import cn.edu.tju.elm.model.Cart;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

/**
 * ClassName: CartMapper
 * Package: cn.edu.tju.elm.mapper
 * Description: 购物车实体和DTO转换器
 *
 * @Author Niu Wenhang
 * @Create 2025/9/20 12:00
 * @Version 1.0
 */
@Mapper(componentModel = "spring")
public interface CartMapper {

    @Mapping(source = "customer.id", target = "customerId")
    @Mapping(source = "business.id", target = "businessId")
    @Mapping(source = "food.id", target = "foodId")
    @Mapping(source = "food.foodName", target = "foodName")
    @Mapping(source = "food.foodPrice", target = "foodPrice")
    CartResponseDTO cartToResponseDTO(Cart cart);

    List<CartResponseDTO> cartsToResponseDTOs(List<Cart> carts);
}
